package com.ks.MyWord;

import java.io.IOException;
import java.util.Date;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@SuppressWarnings("serial")
public class Read extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		resp.getWriter().println("Hello, world");

		DatastoreService ds = DatastoreServiceFactory.getDatastoreService();

		Key googleIDKey = KeyFactory.createKey("GoogleID", "lks21c@gmail.com");

		Key wordKey = KeyFactory.createKey(googleIDKey, "Word", 11);
		resp.getWriter().println(wordKey.toString());

		Key WordListCountKey = KeyFactory.createKey("WordListCount",
				"lks21c@gmail.com");

		try {

			Entity WordListCount = ds.get(WordListCountKey);
			resp.getWriter().println(WordListCount.toString());

			Entity MyGoogleID = ds.get(googleIDKey);
			resp.getWriter().print(MyGoogleID.toString());

			Entity MyWord = ds.get(wordKey);
			resp.getWriter().print(MyWord.toString());

		} catch (Exception e) {

			resp.getWriter().println(e.getMessage());

		}

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		resp.setContentType("text/plain");
		resp.getWriter().println("Hellos, world");

	}
}
